<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>爱贝儿医</title>
    <link rel="stylesheet" href="business/style/common.css?<?=time()?>">
    <link rel="stylesheet" href="business/style/vote/style/index.css?<?=time()?>">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="app/js/common.js"></script>
    <script src="business/js/jquery.js"></script>
    <script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
    (function(win,doc){
        function change(){
            doc.documentElement.style.fontSize=doc.documentElement.clientWidth/375*23.4375+'px';
        }
        change();
        win.addEventListener('resize',change,false);
    })(window,document);
    </script>
</head>

    <!-- 头部开始 -->
    <header>
        <img src="business/style/vote/style/headerback1.png" alt="">
    </header>
    <!-- 头部结束 -->
    <!-- 评选规则 -->
    <div class="rule">
        <h1>本阶段评选规则：</h1>
        <table>
            <tr>
                <td class="ruleT">投票时间：</td>
                <td>8月26日~10月15日</td>
            </tr>
            <tr>
                <td class="ruleT">投票方式：</td>
                <td>网络投票</td>
            </tr>
            <tr>
                <td class="ruleT">投票人：</td>
                <td>限爱贝儿医官方认证医生（在爱贝儿医微信公众号或APP上认证通过的医生）<a href="<?=$user_url?>" class="goQuali">立即认证>></a></td>
            </tr>
            <tr>
                <td class="ruleT">其他说明：</td>
                <td>本阶段投票权重为大众投票10倍，<a href="<?=$vote_act?>" class="goRule">点击查看评选规则</a></td>
            </tr>
        </table>
    </div>
    <!-- 评选规则 -->
    <input type="hidden" value="<?=$user_state?>" id="user_state"/>
    <input type="hidden" class="BiId_all" value="<?=$Bd_id?>"/>
    <input type="hidden" class="voteId_all" value="<?=$vote_re_id?>"/>
    <!-- 列表 -->

    <?php foreach($vote_list as $k =>$v):?>
    <div class="list clearfix">
        <a href="<?=$vote_detail?>&id=<?=$v['id']?>">
        <div class="avatar"><img src="<?=G_SITE_CDN?>/<?=$v['head_img']?>" alt=""></div>
        <div class="listDet">
            <p class="name"><?=$v['name']?></p>
            <p class="position"><?=$v['hospital']?> <?=$v['keshi']?></p>
            <p class="num">当前票数：<span class="voteNums<?=$v['id']?> "><?=$v['vote_num']?></span></p>
        </div>
</a>
        <div class="goVoteBtn aVoteState<?=$v['id']?>" onclick="vote(<?=$v['id']?>)">投票</div>
    </div>

    <?php endforeach;?>
    <!-- 列表 -->


    <!-- 弹出层开始 -->
    <div class="layer" style="display: none" >
        <div>
            <h6>认证医生才可以为TA投票哦~</h6>
            <a href="<?=$user_url?>">立即认证</a>

            <p>医生/护士/医学生均可验证</p>
        </div>
    </div>

    <input type="hidden" value="<?=$caches?>" class="caches"/>
    <div class="layer_enter" style="display:none" >
        <div  class="img">
            <img src="<?= G_SITE_CDN?>/business/style/vote/style/vote32.png">
        </div>
        <div class="Imgclose">
            <img src="<?= G_SITE_CDN?>/business/style/vote/style/vote2_colse.png">
        </div>
    </div>
    <!-- 弹出层结束 -->
</body>
<?php require 'app/templates/common/foot.html'; ?>
</html>
<script>
    $(function(){
        $('.layer').height($(window).height());
        $('.layer_enter').height($(window).height());
        var caches1 = $('.caches').val();
        if(caches1 == ''){
            $('.layer_enter').css('display','block');
            $('.dowmloadFooter').css('display','none');
        }
        var user_state = $("#user_state").val();
        /*页面加载判断投票按钮状态--start*/
        //所有医生的用户id--字符类型
        var much_id = $(".BiId_all").val();

        //将所有用户id -装换为数组类型
        var arr_ids = much_id.split("-");
        //投票记录表中医生id的数据
        var re_bd_id = $(".voteId_all").val().split("-");
        for(var s in arr_ids){
            for(var i in re_bd_id){
                var  a = parseInt(re_bd_id[i]) ;
                var s_id =parseInt(arr_ids[s]);
                if(s_id==a){
                    if(user_state=='已认证'){
                        $(".aVoteState"+a).text("已投票");

                        $(".aVoteState"+a).addClass('div_color');
                    }else{
                        $(".aVoteState"+a).text("认证通过后自动投票");
                        $(".aVoteState"+a).addClass('div_color');
                    }

                }
            }
        }

        /*页面加载判断投票按钮状态--end*/

    });

    function vote(id){
        var user_state = $("#user_state").val();
        if(user_state == '注册' || user_state == '认证'){
            $('.layer').css('display','block');
        }else{
            var useState = 2;
            if(user_state =='认证中'){
                useState = 1;
            }
            var data = {'id':id,'userState':useState};

            var res = common.post('vote','ajax_vote_new',data);
            if(res.message=='已经投过票'){
                common.showMsgBox('您已经给他投过票了！');
            }else if(res.message=='投票失败'){
                common.showMsgBox('投票失败！');
            }

            if(res.result==0){
                if(user_state=="认证中"){
                    $(".aVoteState"+id).text("认证通过后自动投票");
                    $(".aVoteState"+id).addClass('div_color');
                    common.showMsgBox('认证成功后即可显示您的投票信息 : )');
                }else{
                    $(".aVoteState"+id).text("已投票");
                    $(".aVoteState"+id).addClass('div_color');
                    $(".voteNums"+id).text(res.message);
                    common.showMsgBox('感谢您的投票，期待您明天继续参与！');

                }
            }

        }

    }

</script>

<script>
    wx.config({
        debug: false,
        appId: '<?php echo $this->signPackage["appId"];?>',
        timestamp: '<?php echo $this->signPackage["timestamp"];?>',
        nonceStr: '<?php echo $this->signPackage["nonceStr"];?>',
        signature: '<?php echo $this->signPackage["signature"];?>',
        jsApiList: [
            'onMenuShareAppMessage',
            'onMenuShareTimeline',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'onMenuShareQZone'
        ]
    });

    title = '寻找最美儿科医生——第二阶段医生投票火热启动！';
    desc = '关注“爱贝儿医公众号/最美儿医”发现您身边最真实的感动';
    links = '';
    imgUrl = '<?= G_SITE_CDN?>/business/style/vote/style/vote32.png';
    weixinShare(title, desc, links, imgUrl);
</script>